package com.hcb.logsdk.okhttp.request;

import com.hcb.logsdk.okhttp.client.CommonOkHttpClient;
import com.hcb.logsdk.okhttp.listener.DisposeDataHandle;
import com.hcb.logsdk.okhttp.listener.DisposeDataListener;
import com.hcb.logsdk.util.C;

import static com.hcb.logsdk.manager.LOGSDKManager.API_URL;

/**
 * <br/>
 * <br/>
 * 时间：2017/9/25
 */
public class RequestCenter {

    //根据参数发送所有post请求
    public static void postRequest(String url, RequestParams params,
                                   DisposeDataListener listener) {
        CommonOkHttpClient.request(CommonRequest.
                createPostRequest(url, params), new DisposeDataHandle(listener));
    }
    public static void getRequest(String url, RequestParams params,
                                  DisposeDataListener listener, Class<?> clazz) {
        CommonOkHttpClient.request(CommonRequest.
                createGetRequest(url, params), new DisposeDataHandle(listener, clazz));
    }
    public static void postLogRequest(String url, RequestParams params,
                                      DisposeDataListener listener) {
        CommonOkHttpClient.request(CommonRequest.
                createPostRequest(API_URL+url, params), new DisposeDataHandle(listener));
    }

    /**
     * 开始发送LOG
     */
    public static void startSendLog(String deviceNo,DisposeDataListener listener) {

        RequestParams params = new RequestParams();
        params.put("deviceNo", deviceNo);
        RequestCenter.postLogRequest(C.API_SERVER_START_SEND_LOG_URL, params, listener);
    }
    /**
     * 结束发送LOG
     */
    public static void endSendLog(String deviceNo,DisposeDataListener listener) {

        RequestParams params = new RequestParams();
        params.put("deviceNo", deviceNo);
        RequestCenter.postLogRequest(C.API_SERVER_END_SEND_LOG_URL, params, listener);
    }
}
